package com.ayou.eggguard.farm.mapper;

import com.ayou.eggguard.farm.pojo.FodderRecord;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface FodderMapper {
    List<FodderRecord> getPurchaseRecord(String number);

    @Delete("delete from purchase_record where id=#{id}")
    void delete(Integer id);

    @Insert("insert into purchase_record(PurchaseDate, supplier, FeedType, brand, specification, buyer, quantity, unitprice, totalprice, number) " +
            "values(#{purchaseDate},#{supplier},#{feedType},#{brand},#{specification},#{buyer},#{quantity},#{unitPrice},#{totalPrice},#{number})")
    void add(FodderRecord fodderRecord);

    @Update("update purchase_record set PurchaseDate=#{purchaseDate}," +
            "supplier=#{supplier},FeedType=#{feedType},Brand=#{brand}," +
            "Specification=#{specification},buyer=#{buyer},Quantity=#{quantity}," +
            "UnitPrice=#{unitPrice},TotalPrice=#{totalPrice},number=#{number} " +
            "where id=#{id}")
    void update(FodderRecord fodderRecord);
}
